const path = require('path')
const fs = require('fs')
const workDir = process.cwd()
const targetFolder = `${workDir}/target`

function resolve(p) {
  return path.resolve(workDir, p)
}

function removeDir(dir) {
  let files = fs.readdirSync(dir)
  for(var i=0;i<files.length;i++){
    let newPath = path.join(dir,files[i]);
    let stat = fs.statSync(newPath)
    if(stat.isDirectory()){
      //如果是文件夹就递归下去
      removeDir(newPath);
    }else {
     //删除文件
      fs.unlinkSync(newPath);
    }
  }
  fs.rmdirSync(dir)//如果文件夹是空的，就将自己删除掉
}
module.exports = {
  targetFolder,
  resolve,
  removeDir
}